﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

using NUnitResults;

namespace NUnitResultsTests.Mocks
{
    class MockStreamProvider : IStreamProvider
    {
        public Func<Stream> GetStreamImpl { get; set; }

        public Func<String> GetNameImpl { get; set; }

        #region IStreamProvider Members

        public String Name { get { return GetNameImpl(); } }

        public Stream GetStream()
        {
            return GetStreamImpl();
        }

        #endregion

        public static IStreamProvider Create(String resourceName)
        {
            var a = Assembly.GetExecutingAssembly();
            
            return new MockStreamProvider
            {
                GetNameImpl = () => resourceName,
                GetStreamImpl = () => a.GetManifestResourceStream(String.Format("NUnitResultsTests.Resources.{0}", resourceName))
            };
        }
    }
}
